<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>个人支出</title>
    <meta name="renderer" content="webkit">
	<link rel="stylesheet" href="../../layuiadmin/js/finance/js/bootstrap/css/bootstrap.min.css" />
	<script type="text/javascript" src="../../layuiadmin/js/finance/js/jquery.min.js" ></script>
	<script type="text/javascript" src="../../layuiadmin/js/finance/js/bootstrap/js/bootstrap.js" ></script>
    <script type="text/javascript" src="../../layuiadmin/js/finance/js/jquery.cookie.js"></script>
    <script>
        $(document).ready(function(){
            $.post("http://localhost:8080/financePayoutController/payouttypelist",function(msg){
                for(var i=0;i<msg.length;i++){
                    var payoutType=$("#payoutType");
                    if(msg[i].pid==0){
                        var op=$("<option value='"+msg[i].payoutTypeId+"' disabled='false'>"+msg[i].payoutName+"</option>");
                    }else if(msg[i].pid!=100103){
                        var op = $("<option value='"+msg[i].payoutTypeId+"'>"+"&nbsp&nbsp----" + msg[i].payoutName + "</option>");
                    }else{
                        var op = $("<option value='"+msg[i].payoutTypeId+"'>"+"&nbsp&nbsp&nbsp&nbsp----" + msg[i].payoutName + "</option>");
                    }
                    payoutType.append(op);
                }
            });
            $.post("http://localhost:8080/financePayoutController/caseid",function(msg){
                for(var i=0;i<msg.length;i++){
                    var caseid=$("#caseid");
                    if(msg[i].ppid==0){
                        var op=$("<option value='"+msg[i].caseTypeid+"'>"+msg[i].typeName+"</option>");
                    }else{
                        var op=$("<option value='"+msg[i].caseTypeid+"'>" + "&nbsp&nbsp----" +msg[i].typeName+"</option>");
                    }
                    caseid.append(op);
                }
            });
            $.post("http://localhost:8080/financePayoutController/paytype",function(msg) {
                for(var i=0;i<msg.length;i++){
                    var paytype=$("#paytype");
                    var op=$("<option value='"+msg[i].payId+"'>"+msg[i].payType+"</option>");
                    paytype.append(op);
                }
            });
            list();
        });
        function  list() {
            var cookie=$.cookie("redisName");
            var payoutType=$("#payoutType").val();
            var caseId=$("#caseid").val();
            var paytype=$("#paytype").val();
            var enteringdate=$("#enteringdate").val();
            var inputdate=$("#inputdate").val();
            var caselawid=$("#caselawid").val();
                $.post("http://localhost:8080/financePayoutController/payoutlist",
                    {
                        "payoutType": payoutType,
                        "caseId": caseId,
                        "paytype": paytype,
                        "inputdate":inputdate,
                        "enteringdate":enteringdate,
                        "cookie":cookie,
                        "caselawid":caselawid
                    },
                    function (msg) {
                    var tab = $("#tab");
                    if(msg.length==0){
                        $("#tab  tr:not(:first)").remove();
                        var tr=$("<tr></tr>");
                        var td=$("<td colspan='7'>没有相关数据</td>");
                        tr.append(td);
                        tab.append(tr);
                        var caselawid1=$("#caselawid").val("");
                        var enteringdate1=$("#enteringdate").val("");
                        var inputdate1=$("#inputdate").val("");
                    }else {
                        $("#tab  tr:not(:first)").remove();
                        var sum = 0;
                        var tr1 = $("<tr></tr>");
                        for (var i = 0; i < msg.length; i++) {
                            var myDate = new Date(msg[i].enteringDate);
                            var year=myDate.getFullYear();
                            var month=myDate.getMonth()+1;
                            var date=myDate.getDate();
                            var now=year+'-'+month+"-"+date;
                            var inout=new Date(msg[i].inoutDate);
                            var year1=inout.getFullYear();
                            var month1=inout.getMonth()+1;
                            var date1=inout.getDate();
                            var now1=year1+'-'+month1+"-"+date1;
                            var tr = $("<tr></tr>");
                            var td1 = $("<td>" + msg[i].payoutTypeId.payoutName + "</td>");
                            var td2 = $("<td>" + now1 + "</td>");
                            var td3 = $("<td>" + msg[i].inoutMoney + "</td>");
                            var td4 = $("<td>" + msg[i].payId.payType + "</td>");
                            var td5 = $("<td>" + msg[i].caseId.caseId + "</td>");
                            var td6 = $("<td>" + now + "</td>");
                            var td7 = $("<td>" + msg[i].remark + "</td>");
                            tr.append(td1);
                            tr.append(td2);
                            tr.append(td3);
                            tr.append(td4);
                            tr.append(td5);
                            tr.append(td6);
                            tr.append(td7);
                            tab.append(tr);
                            sum += msg[i].inoutMoney;
                        }
                        tr1.append("<td>总计收支金额</td>");
                        tr1.append("<td colspan='6'>" + sum + "(元)</td>");
                        tab.append(tr1);
                    }
                });
        }
    </script>
</head>
<body>
<div class="container-fluid">
    <form class="form-horizontal form-inline" >
        <div class="row" style="margin-top: 15px">
            <div class="col-lg-12">
                <input class="form-control" type="text" id="caselawid" placeholder="案号"/>
                <select class="form-control" id="payoutType" style="width: 400px">
                    <option value="-1">请选择收支类型</option>
                </select>
                <select class="form-control" id="paytype">
                    <option value="-1">请选择支付类型</option>
                </select>
                <select class="form-control" id="caseid">
                    <option value="-1">请选择案件类型</option>
                </select>
                <label for="inputdate">发生日期</label>
                <input class="form-control" type="date" id="inputdate" value="-1"/>
                <div style="margin-top: 15px">
                    <label for="enteringdate">录入日期</label>
                    <input class="form-control" type="date" id="enteringdate"/>
                    <button type="button" onclick="list()" class="btn btn-success">检索</button>

                </div>
            </div>
        </div>
        <div style="margin-top: 15px">
        <table class="table table-hover table-bordered" style="text-align: center" id="tab">
            <tr style="font-weight: bold">
                <td>收支类别</td>
                <td>发生日期</td>
                <td>收支金额(元)</td>
                <td>支付方式</td>
                <td>案号</td>
                <td>录入日期</td>
                <td>备注</td>
            </tr>
        </table>
        </div>
</form>
</div>
</body>
</html>
